package com.xbongbong.paas.enums;


import com.xbongbong.i18n.util.I18nMessageUtil;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * @ClassName MobileModeTypeEnum
 * @Description 首页是否是自定义
 * @Author mengna.Deng
 * @Date 2021/11/29 19:07
 * @Version 1.0
 */
public enum HomePageCustomTypeEnum {
    /**
     * 经典模式
     */
    NOT_CUSTOM(0,"notCustom", "enum.homePageCustomType.name.not_custom"),
    /**
     * 专注模式
     */
    IS_CUSTOM(1,"isCustom", "enum.homePageCustomType.name.is_custom"),
            ;

    public int code;
    public String alias;
    public String name;
    public String value;

    HomePageCustomTypeEnum(Integer code, String alias, String name){
        this.code = code;
        this.alias = alias;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getAlias() {
        return alias;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }


    public static List<HomePageCustomTypeEnum> getAllEnum(){
        List<HomePageCustomTypeEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public static HomePageCustomTypeEnum getByAlias(String alias) {
        if(alias != null){
            for (HomePageCustomTypeEnum cacheCode : values()) {
                if (Objects.equals(cacheCode.getAlias(), alias)) {
                    return cacheCode;
                }
            }
        }
        return null;
    }

    public static List<String> getAliasList() {
        List<String> alias = new ArrayList<>();
        for (HomePageCustomTypeEnum cacheCode : values()) {
            alias.add(cacheCode.getAlias());
        }
        return alias;
    }
}
